// ==========================================================================
// GFast自动生成controller操作代码。
// 生成日期：2024-06-18 17:06:48
// 生成路径: internal/app/app/controller/app_news_category.go
// 生成人：gfast
// desc:文章分类
// company:云南奇讯科技有限公司
// ==========================================================================

package controller

import (
	"context"

	"github.com/tiger1103/gfast/v3/api/v1/app"
	"github.com/tiger1103/gfast/v3/internal/app/app/service"
	systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller"
)

type appNewsCategoryController struct {
	systemController.BaseController
}

var AppNewsCategory = new(appNewsCategoryController)

// List 列表
func (c *appNewsCategoryController) List(ctx context.Context, req *app.AppNewsCategorySearchReq) (res *app.AppNewsCategorySearchRes, err error) {
	res = new(app.AppNewsCategorySearchRes)
	res.AppNewsCategorySearchRes, err = service.AppNewsCategory().List(ctx, &req.AppNewsCategorySearchReq)
	return
}

// Get 获取文章分类
func (c *appNewsCategoryController) Get(ctx context.Context, req *app.AppNewsCategoryGetReq) (res *app.AppNewsCategoryGetRes, err error) {
	res = new(app.AppNewsCategoryGetRes)
	res.AppNewsCategoryInfoRes, err = service.AppNewsCategory().GetById(ctx, req.Id)
	return
}

// Add 添加文章分类
func (c *appNewsCategoryController) Add(ctx context.Context, req *app.AppNewsCategoryAddReq) (res *app.AppNewsCategoryAddRes, err error) {
	err = service.AppNewsCategory().Add(ctx, req.AppNewsCategoryAddReq)
	return
}

// Edit 修改文章分类
func (c *appNewsCategoryController) Edit(ctx context.Context, req *app.AppNewsCategoryEditReq) (res *app.AppNewsCategoryEditRes, err error) {
	err = service.AppNewsCategory().Edit(ctx, req.AppNewsCategoryEditReq)
	return
}

// Delete 删除文章分类
func (c *appNewsCategoryController) Delete(ctx context.Context, req *app.AppNewsCategoryDeleteReq) (res *app.AppNewsCategoryDeleteRes, err error) {
	err = service.AppNewsCategory().Delete(ctx, req.Ids)
	return
}
